import { getApi, postApi, service } from "../../config/request";
import { AxiosPromise } from "axios";

// 菜肴列表
export const reqDishList = (params: object = {}): AxiosPromise => {
  return postApi("/fridge_business/platform/dish/query_page", params);
};
// 新增菜肴
export const reqAddDish = (params: object = {}): AxiosPromise => {
  return postApi("/fridge_business/platform/dish/insert", params);
};

// 修改菜肴
export const reqModifyDish = (params: object = {}): AxiosPromise => {
  return postApi("/fridge_business/platform/dish/update", params);
};
// 删除
export const reqDeleteDish = (params: object = {}): AxiosPromise => {
  return postApi("/fridge_business/platform/dish/delete", params, {
    "Content-Type": "application/x-www-form-urlencoded",
  });
};

// 菜肴类型列表(分页)
export function reqDishTypeList(params: object = {}): AxiosPromise {
  return getApi("/fridge_business/platform/dish_type/query_page", {
    params,
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
  });
}

// 导出菜肴
export const reqExport = (params: object = {}): AxiosPromise => {
  return postApi("/fridge_business/platform/dish/export", params);
};
// 导入菜肴信息
export const reqImportDishes = (file: File): AxiosPromise => {
  const formData = new FormData();
  formData.append("file", file);
  return postApi("/fridge_business/platform/dish/import_dish", formData, {
    "Content-Type": "multipart/form-data",
  });
};

// 导入菜肴信息_覆盖
export const reqImportCover = (params: object = {}): AxiosPromise => {
  return postApi("/fridge_business/platform/dish/import_dish_cover", params);
};

// 下载菜肴模板
export function reqLoadTemplate(params: object = {}): AxiosPromise {
  return getApi("/fridge_business/platform/dish/download_dish_template", {
    params,
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
    responseType: "blob",
  });
}

// 新增菜肴类型
export const reqAddType = (params: object = {}): AxiosPromise => {
  return postApi("/fridge_business/platform/dish_type/insert", params);
};

// 修改菜肴类型
export const reqModifyType = (params: object = {}): AxiosPromise => {
  return postApi("/fridge_business/platform/dish_type/update", params);
};
// 删除菜肴类型
export const reqDeleteType = (params: object = {}): AxiosPromise => {
  return postApi("/fridge_business/platform/dish_type/delete", params, {
    "Content-Type": "application/x-www-form-urlencoded",
  });
};

// 餐段列表(分页)
export function reqMealList(params: object = {}): AxiosPromise {
  return getApi("/fridge_business/platform/meal_segment/query_page", {
    params,
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
  });
}

// 新增餐段信息
export const reqAddMeal = (params: object = {}): AxiosPromise => {
  return postApi("/fridge_business/platform/meal_segment/insert", params);
};

// 修改餐段信息
export const reqModifyMeal = (params: object = {}): AxiosPromise => {
  return postApi("/fridge_business/platform/meal_segment/update", params);
};

// 删除餐段信息
export const reqDeleteMeal = (params: object = {}): AxiosPromise => {
  return postApi("/fridge_business/platform/meal_segment/delete", params, {
    "Content-Type": "application/x-www-form-urlencoded",
  });
};
